package com.sharing.controller;

import com.sharing.common.Page;
import com.sharing.common.Result;
import com.sharing.domain.User;
import com.sharing.domain.UserLike;
import com.sharing.service.UserLikeService;
import jdk.internal.dynalink.linker.LinkerServices;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.net.Inet4Address;
import java.util.List;

/**
 * @author MingTian
 * @version 1.0
 * @description TODO
 * @date 2023/4/3 21:11
 */
@RestController
@RequestMapping("/userlike")
public class UserLikeController {
    @Autowired
    private UserLikeService userLikeService;

    /**
     * 查询指定用户所关注的所有用户
     * @param userId
     * @param page
     * @param size
     * @return
     */
    @GetMapping
    public Result<Page<User>> selectLikeUsersByUserId(Integer userId, Integer page, Integer size) {
        return userLikeService.selectLikeUsersByUserId(userId, page, size);
    }

    /**
     * 查询关注该用户的所有用户
     * @param userId
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/like")
    public Result<Page<User>> selectUsersByLike(Integer userId, Integer page, Integer size) {
        return userLikeService.selectUsersByLike(userId, page, size);
    }

    /**
     * 新增关注用户
     * @param userLike
     * @return
     */
    @PostMapping
    public Result<Integer> insertLikeUser(@RequestBody UserLike userLike) {
        return userLikeService.insertLikeUser(userLike);
    }

    /**
     * 删除关注用户
     * @param userLike
     * @return
     */
    @DeleteMapping
    public Result<Integer> deleteLikeUser(@RequestBody UserLike userLike) {
        return userLikeService.deleteLikeUser(userLike);
    }
}
